#define _CRT_SECURE_NO_WARNINGS 1
#include<vector>
#include<queue>
class Solution {
public:
    std::vector<int> getLeastNumbers(std::vector<int>& arr, int k) {
        if (k == 0)
        {
            return {};
        }
        std::vector<int> ret;
        std::priority_queue<int> pq(arr.begin(), arr.begin() + k);
        for (size_t i = k; i < arr.size(); i++)
        {
            if (arr[i] < pq.top())
            {
                pq.pop();
                pq.push(arr[i]);
            }
        }
        while (!pq.empty())
        {
            int top = pq.top();
            pq.pop();
            ret.push_back(top);
        }
        return ret;
    }
};